﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Core.Module;
using CoreIOC;
using Ron.MQTest;
using Ron.MQTest.Utils;
using DotNetCore.CAP;
using Core.Module.CapSubsribeService;
using Core.Module.SerializerService;

namespace WebClient.Controllers
{
    public class TestController : Controller
    {
        private readonly IUserTestService _userTestService;
        private readonly ICapPublisher _capBus;
        public TestController(IUserTestService userTestService, ICapPublisher capPublisher)
        {
            _userTestService = userTestService;
            _capBus = capPublisher;
        }
        public IActionResult Index()
        {
             

            var service = ServiceLocator.GetService<IMsgSerializer>();
            string s=service.Serialize(new List<string>() { "sssss", "xxxxx" });
            return Json("");
        }
        public IActionResult Send()
        {
            UserTestService service = (UserTestService)Activator.CreateInstance(typeof(UserTestService));
           var sum= service.Add(13123, 121);
            List<DtoModel> list = new List<DtoModel>();        
            RedisHelper.Set("xxx", 1212312);
            for(int i = 0;i<1; i++)
            {
                list.Add(new DtoModel
                {
                    UserName = "UserName",
                    UserName2 = "UserName2",
                    UserName3 = "UserName3",
                    UserName4 = "UserName4"
                });
            }
            for (int i = 0; i < 1; i++)
            {
                Task.Run(() => _capBus.Publish("helloworld", list));               
            }
            return Json("ok");
        }
    }


}